/**************************************************
Do-file replicating all results in:
	Endogenous Price Commitment, Sticky and Leadership Pricing: 
	Evidence from the Italian Petrol Market 
Published in: 
	International Journal of Industrial Organization, vol. 40(C), pages 32-48.
Authors: 
	Patrick Andreoli-Versbach & Jens-Uwe Franck 
Contact author: 
	Patrick Andreoli-Versbach
E-Mail: 
	patrick.andreoliversbach@gmail.com 
**************************************************/


/****************STRUCTURE*************************
First Part: Italian daily firm-level prices 
	Tables: 1, 3, 4 and 8 
	Figures: 1, 3 and 4

Second Part: EU countries weekly average prices
	Tables: 2 and 5 
	Figures: 2

Third Part: Synthetic control group
	Tables: 6 and 7 
	Figures: 5

Fourth Part: In-State and In-Time placebo
	Tables: 9 and 10 
 
**************************************************/
	
	clear all
	set more off 
	
********************
** Set up globals **
********************           
	 
	 // NOTE: Save the data in a folder and then insert the folder path in the globals below. 
	 //		  For example: global folder "C:\Desktop\Replication"
	 

	 // Save data here: 
	global folder  "[ADD FOLDER PATH WITH DATA]"
	
	// Output will go here:
	global output  "[ADD ANY FOLDER PATH]"

	cd "$output"
	
	
******************************************************************************** 
*************************** Start - First Part *********************************
********************************************************************************
use "$folder\Raw Data Italian firm-level prices.dta", clear

********************************
** 		Generate Variables    **
********************************  

// Reshape wide
reshape wide price, i(daily)
tsset daily, daily

// Dummy for price changes
foreach x of varlist price*  {
               
				gen pr_ch_am_`x'=abs(`x'-L.`x')
				gen pr_ch_`x'=0
				replace  pr_ch_`x'=1 if pr_ch_am_`x'>0  & !missing(pr_ch_am_`x')
				replace  pr_ch_`x'=. if daily==td(01jan2003)
			
        }

// Dummy for perfectly aligned competitors; Note Price1=ENI 	  
forval num = 2/9 {

             gen al_`num'=0
		     replace al_`num'=1 if float(price`num')==float(price1)
          
		  }

// Number of aligned competitors to leader
egen nr_align=rowtotal(al_2-al_9)

// Absolute price difference with respect to the leader
forval num = 2/9 {
                 gen abs_pdif_`num'= abs(price`num'- price1)
          }

// Absolute percentage price difference with respect to the leader   
forval num = 2/9 {
                 gen abs_perc_dif_`num'= abs((price`num'- price1)/price1)
          }

// Price difference with respect to the leader
forval num = 2/9 {
                 gen pdif_`num'= price`num'- price1
          }

// Average daily price difference with respect to leader	    
egen av_pdif=rowmean(pdif_2-pdif_9)

// Average daily price standard deviation	    
egen pr_sd = rowsd(price1-price9)

//Percentage price change
forvalues k = 1/9 {
                gen del_price`k'=D.price`k'
		        gen perc_p_ch`k'=del_price`k'/L.price`k'
        }
//Absolute percentage price change
forvalues k = 1/9 {
                gen abs_perc_p_ch`k'=abs(perc_p_ch`k')
        }

// Time period after ENI's sticky pricing announcement
gen pcai=(daily>=td(07oct2004))
label define  pcaiName 0 "Pre Sticky Pricing" 1 "Sticky Pricing" 
label values  pcai pcaiName

// Leader price change dummy and lags
gen pr_ch_price1_policy= pcai*pr_ch_price1

forvalues t = 0(1)6 {

		gen enichpL`t' = L`t'.pr_ch_price1
		gen enichp_policyL`t' = pcai*L`t'.pr_ch_price1_policy 

		}
		
// Positive and Negative price changes
gen pos_ENI=(price1-L.price1>0)
gen neg_ENI=(price1-L.price1<0)

forvalues t=0(1)6 {

gen enicprPOS`t'=L`t'.pos_ENI*enichpL`t'
gen enicprNEG`t'=L`t'.neg_ENI*enichpL`t'

}

// Label Variables
label var price1 "ENI"
label var price2 "API"
label var price3 "ERG"
label var price4 "ESSO"
label var price5 "IP"
label var price6 "Q8"
label var price7 "SHELL"
label var price8 "TAMOIL"
label var price9 "TOTAL"
label var platts "Platts Cif. Med."
label var nr_align "Nr. Aligned Firms"
label var av_pdif "Aver. Price Dif. to leader"
label var pr_sd "Daily St. Dev. of Prices"

save  "$output\Replication_Data_AnalysisIT.dta", replace

********************************
** Graphs and Tables          **
********************************  

use  "$output\Replication_Data_AnalysisIT.dta", clear

*********************************
***Figure 1 - Cartel Formation***
*********************************
graph tw (tsline price2) ///
 (tsline price3)(tsline price4)(tsline price5)(tsline price6) ///
 (tsline price7)(tsline price8)(tsline price9) ///
(tsline price1  , cmissing(no) lpattern("-.-.") clcolor(black) clwidth(medium) ) ///
 (tsline platts, lp(dash)) ,  ///
 tlabel( 01jan2003(185)01jul2004 06oct2004 01jan2005 25mar2005 ///
 , format(%tdMon_CCYY)  labsize(small) ) ///
 xtitle("")  tline(06oct2004) tline(25mar2005) ///
 ytitle("Firms' Prices, Costs (Euro/Liter)") title(Figure I: Cartel Formation) ///
 legend(  label(1 "Api")label(2 "Erg")label(3 "ESSO")label(4 "IP")label(5 "Q8") ///
 label(6 "Shell")label(7 "Tamoil")label(8 "Total") ///
label(9 "ENI") label(10 "Platts") c(5)) xsize(12) ///
ysize(7) saving("Fig1-CartForm", replace) 

***********************************************
***Figure 3 - Alignment and Price Dispersion***
***********************************************
//Part 1: Number of Aligned Firms
tw hist nr_align, by(pcai, note(""))  ///
xtitle("Number of Competitors Aligned to ENI") disc name(nr_align, replace)

//Part 2: StD 
tw (kdensity  pr_sd if pcai==1,  lpattern("----") ) ///
(kdensity  pr_sd if pcai==0) if pr_sd<.0095,  legend( label( 1 "Sticky Pricing" ) ///
label( 2 "Pre Sticky Pricing")) title("Price Standard Deviation") ///
xtitle("Daily Standard Deviation of Prices") ///
ytitle(Kernel Density) name(std, replace)

// Combine Part 1&2
graph combine  nr_align std, xsize(12) ysize(7) ///
title("Figure III: Alignment and Price Dispersion") ///
saving("Fig3-Price Alignment and StDev", replace)


**********************************
***Table 1 - Summary statistics***
**********************************
reg price* platts nr_align av_pdif pr_sd
outreg2 using Tab1_ITsummary, sum replace st( mean sd min max N) excel side label


*************
***T-Tests***
*************
ttest nr_align  , by( pcai)
ttest av_pdif  , by( pcai)

********************************************************
***Table 3 - Frequency and Magnitude of price changes***
********************************************************
//Part 1 - Individual firms
use  "$output\Replication_Data_AnalysisIT.dta", clear
keep daily price* pcai abs_perc_p_ch*  pr_ch_price* 
reshape long price pr_ch_price abs_perc_p_ch, i(daily)
xtset _j daily
by _j: gen cump=sum(pr_ch_price)
gen one=1
bysort _j cump:	egen days_change_p=total(one)  
drop one cump

// Average number of days between price changes
sum days_change_p if   pr_ch_price==1  , d
reshape wide price pr_ch_price abs_perc_p_ch days_change_p, i(daily) 

gen T1=0
gen T2=0
gen T3=0

gen S1=0
gen S2=0
gen S3=0
gen firm=""

forval num = 1/9 {

local n = (`num'-1)*2+1 
local k =(`num'-1)*2+2
               
		   ttest abs_perc_p_ch`num' if abs_perc_p_ch`num'!=0 , by(pcai)

		   replace T1= r(mu_1) in  `n'
		   replace T1= r(sd_1) in  `k'
		   
		   replace T2= r(mu_2) in  `n'
		   replace T2= r(sd_2) in  `k'
		     
		   replace T3= r(mu_2)-r(mu_1) in  `n'
		   replace T3= -r(t) in  `k'
          }


forval num = 1/9 {

local n = (`num'-1)*2+1 
local k =(`num'-1)*2+2
               
		   ttest days_change_p`num' if   pr_ch_price`num'==1  , by(pcai)
		   
		   replace S1= r(mu_1) in  `n'
		   replace S1= r(sd_1) in  `k'
		   
		   replace S2= r(mu_2) in  `n'
		   replace S2= r(sd_2) in  `k'
		     
		   replace S3= r(mu_2)-r(mu_1) in  `n'
		   replace S3= -r(t) in  `k'
          
		  }

keep T1 T2 T3 S1 S2 S3 firm

forvalues x=1(1)3 {

rename T`x' Column_`x'
local y=`x'+3
rename S`x' Column_`y'

}

gen obs=_n

replace firm="ENI" if obs==1
replace firm="API" if obs==3
replace firm="ERG" if obs==5
replace firm="ESSO" if obs==7
replace firm="IP" if obs==9
replace firm="Q8" if obs==11
replace firm="SHELL" if obs==13
replace firm="TAMOIL" if obs==15
replace firm="TOTAL" if obs==17

drop if obs>18
drop obs

save "$output\Tab3-IndivFirms.dta", replace

//Part 2 - All firms
use  "$output\Replication_Data_AnalysisIT.dta", clear
keep daily price* pcai abs_perc_p_ch*  pr_ch_price*
reshape long price pr_ch_price abs_perc_p_ch, i(daily)
xtset _j daily
by _j: gen cump=sum(pr_ch_price)
gen one=1
bysort _j cump:	egen days_change_p=total(one)  

drop one cump

gen T1=0
gen T2=0
gen T3=0

gen S1=0
gen S2=0
gen S3=0
gen firm="All Firms" in 1

local n = 1 
local k = 2
               
		ttest abs_perc_p_ch if abs_perc_p_ch!=0 , by(pcai)

		   replace T1= r(mu_1) in  `n'
		   replace T1= r(sd_1) in  `k'
		   
		   replace T2= r(mu_2) in  `n'
		   replace T2= r(sd_2) in  `k'
		     
		   replace T3= r(mu_2)-r(mu_1) in  `n'
		   replace T3= -r(t) in  `k'
 
		 ttest days_change_p`num' if   pr_ch_price`num'==1  , by(pcai)
		   
		   replace S1= r(mu_1) in  `n'
		   replace S1= r(sd_1) in  `k'
		   
		   replace S2= r(mu_2) in  `n'
		   replace S2= r(sd_2) in  `k'
		     
		   replace S3= r(mu_2)-r(mu_1) in  `n'
		   replace S3= -r(t) in  `k'
          
keep T1 T2 T3 S1 S2 S3 firm

forvalues x=1(1)3 {

rename T`x' Column_`x'
local y=`x'+3
rename S`x' Column_`y'

}

gen obs=_n
drop if obs>2
drop obs

save "$output\Tab3-AllFirms.dta", replace

// Combine Tables
use "$output\Tab3-AllFirms.dta", clear
append using "$output\Tab3-IndivFirms.dta"
order firm Column_1 Column_2 Column_3 Column_4 Column_5 Column_6
export excel using "$output\Tab3-Magnitude and Frequency.xls", firstrow(variables) replace


**********************************
***Table 4 - Price Leadership  ***
**********************************
use  "$output\Replication_Data_AnalysisIT.dta", clear

keep  daily pcai al_* enichp_policyL* enichpL* abs_perc_dif_* enicprPOS* enicprNEG*
reshape long  al_ abs_perc_dif_ ,  i(daily)
xtset   _j daily
xi, noomit i._j

//Table
logit  al_ pcai enichp_policyL0 enichp_policyL1 enichp_policyL2 enichp_policyL3 ///
enichp_policyL4 enichp_policyL5 enichp_policyL6 ///
 enichpL0 enichpL1 enichpL2 enichpL3 enichpL4 enichpL5 enichpL6  _I_j_2-_I_j_9 
mfx compute
outreg2 using Tab4_Pleader , replace excel  symbol(***, **, *)
outreg2 using Tab4_Pleader, mfx ctitle(mfx) append excel  symbol(***, **, *)
xtreg abs_perc_dif_ pcai enichp_policyL0 enichp_policyL1 enichp_policyL2 ///
enichp_policyL3 enichp_policyL4 enichp_policyL5 enichp_policyL6 ///
enichpL0 enichpL1 enichpL2 enichpL3 enichpL4 enichpL5 enichpL6, fe
outreg2 using Tab4_Pleader, append excel  symbol(***, **, *) 
xtreg abs_perc_dif_  enicprPOS0 enicprPOS1 enicprPOS2 enicprPOS3 enicprPOS4 ///
enicprPOS5 enicprPOS6 enicprNEG0 enicprNEG1 enicprNEG2 enicprNEG3 enicprNEG4 ///
enicprNEG5 enicprNEG6  if pcai==1, fe
outreg2 using Tab4_Pleader, append excel  symbol(***, **, *) 

// Test-> alignment after positive vs. negative price changes
lincom enicprPOS0 - enicprNEG0 + enicprPOS1- enicprNEG1+ enicprPOS2- enicprNEG2+ ///
enicprPOS3- enicprNEG3 +enicprPOS4 -enicprNEG4 +enicprPOS5 -enicprNEG5 ///
+enicprPOS6 -enicprNEG6

//Count number of price changes, positive negative, total
tab enichpL0 if pcai==1   & _j==2
tab enicprPOS0 if pcai==1 & _j==2
tab enicprNEG0 if pcai==1 & _j==2


****************************************
***Figure 4 - Price Interdependence  ***
****************************************
use  "$output\Replication_Data_AnalysisIT.dta", clear

keep  daily pcai enichp_policyL* enichpL* abs_perc_dif_* enicprPOS* enicprNEG*
reshape long  al_ abs_perc_dif_ ,  i(daily)
xtset   _j daily

xtreg abs_perc_dif_ pcai enichp_policyL0 enichp_policyL1 enichp_policyL2 ///
enichp_policyL3 enichp_policyL4 enichp_policyL5 enichp_policyL6 ///
enichpL0 enichpL1 enichpL2 enichpL3 enichpL4 enichpL5 enichpL6, fe

gen pre_m=0
gen pre_se=0
gen pre_df=0

gen post_m=0
gen post_se=0
gen post_df=0


forval num = 0/6 {

local k= `num' +1

	lincom _cons + enichpL`num' 

	replace pre_m= r(estimate) in `k' 
	replace pre_se= r(se) in `k' 
	replace pre_df= invttail( r(df) ,.025) in `k' 		
			}


forval num = 0/6 {

local k= `num' +1

	lincom _cons + enichp_policyL`num' + enichpL`num' + pcai

	replace post_m=r(estimate) in `k' 
	replace post_se= r(se) in `k' 
	replace post_df= invttail( r(df) ,.025) in `k'	
			}

keep pre* post*		
gen time=_n
drop if time>7
gen days = time -1
gen min95_0= pre_m- pre_df*pre_se
gen max95_0= pre_m+ pre_df*pre_se
gen min95_1= post_m-post_df*post_se
gen max95_1= post_m+post_df*post_se
rename pre_m  Mean0
rename post_m Mean1 
keep Mean0 Mean1  min95_0 max95_0 min95_1 max95_1 days

// 2R&R Figure 4 left panel
tw (rcap min95_0 max95_0 days , lp(dash)   fc(none)  color(dkgreen) msize(medium) ) ///
(scatter  Mean0 days ,   lp(dash) connect(l) mlabcolor(black)  msymbol(S) ///
msize(vsmall)  color(dkgreen) mlabpo(12)) ///
(rcap min95_1 max95_1 days ,    fc(none)  color(dkorange) msize(medium)   ) ///
(scatter  Mean1 days ,   connect(l) mlabcolor(black)  msymbol(D) msize(vsmall)  ///
color(dkorange) mlabpo(12) ) , ///
xlabel(0 (1) 6) ylabel(-0.01(0.01)0.06) ytitle("Absolute % Price Difference to Leader")  /// 
xtitle("Days After a Price Change by the Leader") ///
legend(label(1 "") label(3 "") label(2 "Pre Sticky Pricing") ///
label(4 "Sticky Pricing") order(2 4) row(2) )  ///
title("Dynamic Price Alignment" "to the Leader") saving(Fig4_leftpanel, replace)

// 2R&R Figure 4 right panel
use  "$output\Replication_Data_AnalysisIT.dta", clear

keep  daily pcai enichp_policyL* enichpL* abs_perc_dif_* enicprPOS* enicprNEG*
reshape long  al_ abs_perc_dif_ ,  i(daily)
xtset   _j daily
			
gen days=_n-1

gen POS_m =0 
gen POS_se=0
gen POS_df=0

gen NEG_m=0
gen NEG_se=0			 
gen NEG_df=0

xtreg abs_perc_dif_  enicprPOS0 enicprPOS1 enicprPOS2 enicprPOS3 enicprPOS4 ///
enicprPOS5 enicprPOS6 enicprNEG0 enicprNEG1 enicprNEG2 enicprNEG3 enicprNEG4 ///
enicprNEG5 enicprNEG6  if pcai==1, fe

forval num = 0/6 {

local k= `num' +1

	lincom _cons + enicprPOS`num' 

	replace POS_m=r(estimate) in `k' 
	replace POS_se= r(se) in `k' 
	replace POS_df= invttail( r(df) ,.025) in `k' 
			
			}

forval num = 0/6 {

local k= `num' +1

	lincom _cons + enicprNEG`num'

	replace NEG_m=r(estimate) in `k' 
	replace NEG_se= r(se) in `k' 
	replace NEG_df= invttail( r(df) ,.025) in `k' 

			
			}
gen min95POS= POS_m-POS_df*POS_se
gen max95POS= POS_m+POS_df*POS_se

gen min95NEG= NEG_m-NEG_df*NEG_se
gen max95NEG= NEG_m+NEG_df*NEG_se

tw rcap min95POS max95POS days , lp(solid) lw(medthin)     fc(none)  lc(dkorange) msize(medium)    || ///
scatter POS_m days , connect(l)  mlabcolor(orange)  msymbol(S) msize(vsmall)  color(dkorange) mlabpo(12) || ///
rcap min95NEG max95NEG days , lp(solid) lw(medthin)    fc(none)  lc(dkgreen) msize(medium)    || ///
( scatter NEG_m days , connect(l ) lp(dash) mlabcolor(green)  msymbol(D) ///
msize(vsmall)  color(green) mlabpo(12)) if days<7 , ///
 ytitle("") xlabel(0(1)6) xsize(12) ysize(7) ylabel(-0.01(0.01)0.06) ///
 xtitle("Days After a Price Change by the Leader (Sticky Pricing Period Only)") ///
 legend(label(1 "") label(2 "Leader's Positive Price Changes" ) label(3 "") ///
 label(4 "Leader's Negative Price Changes" ) order(2 4) row(2) )  ///
title("Competitors' Response to Positive" "and Negative Price Changes") ///
saving(Fig4_rightpanel, replace)

// Combine both graphs
graph combine "$output\Fig4_leftpanel.gph"  ///
"$output\Fig4_rightpanel.gph" , ///
 xcom ysize(7) xsize(13) ///
saving(Fig4_Complete, replace) title("Figure IV: Price Interdependence to Leader")


****************************************
***Table 8 - Firm level mark-up      ***
****************************************
use  "$output\Replication_Data_AnalysisIT.dta", clear

keep  daily pcai price* platts
reshape long  price ,  i(daily)
xtset   _j daily
gen markup = 1000*(price-platts)

reg markup   i._j daily  if pcai==0, robust
outreg2 using Tab8_markup, sideway replace excel  symbol(***, **, *)
xi: reg markup i._j daily if pcai==1 , robust
outreg2 using Tab8_markup,sideway append  excel  symbol(***, **, *)
xi: reg markup c.pcai##i._j daily, robust
outreg2 using Tab8_markup,sideway append excel  symbol(***, **, *)
 

******************************************************************************** 
*************************** END - First Part ***********************************
********************************************************************************





******************************************************************************** 
*************************Start - Second Part ***********************************
********************************************************************************


//Data
use  "$folder\Raw Data EU avg prices.dta" , clear

gen Date=date(date,"DMY")
format Date %td

keep Date _j price brenteuml

********************************
** 		Generate Variables    **
********************************  
reshape wide price, i(Date)
egen Mean_EU=rowmean(price1-price9 )

gen pcai=(Date>td(06oct2004))

//Label
label var price1 "Italy"
label var price2 "Belgium"
label var price3 "Germany"
label var price4 "Spain"
label var price5 "France"
label var price6 "Greece"
label var price7 "Netherlands"
label var price8 "Portugal"
label var price9 "Austria"
label var Mean_EU "Mean EU price"
label var brenteuml "Brent"

save "$output\EU_Data_Analysis.dta", replace

****************************************
*** Table 2 - EU Summary Statistics  ***
****************************************

use "$output\EU_Data_Analysis.dta", clear
reg price* Mean_EU brenteuml 
outreg2 using Tab2_EUsummary, sum replace st( mean sd min max N) excel side label

****************************************
*** Table 5 - Dif-in-Dif			 ***
****************************************
use "$output\EU_Data_Analysis.dta", clear
reshape long price, i(Date)
xtset _j Date
gen yr=year(Date)
gen month=month(Date)
gen IT_pXPC=0
replace IT_pXPC=1 if pcai==1 & _j==1
gen IT_p=0
replace IT_p=1 if _j==1
bys _j: gen time=_n
xtset _j time

xi: reg price IT_pXPC time  pcai    i._j , vce( cluster _j)
outreg2 using Tab5_DiD, replace excel  symbol(***, **, *)
xi: reg price IT_pXPC time  pcai  L(0/4).brenteuml  i._j  , vce(cluster _j)
outreg2 using Tab5_DiD, append excel  symbol(***, **, *)
xi: reg price IT_pXPC time  pcai  L(0/4).brenteuml   i._j  i.yr i.month  , vce(cluster _j)
outreg2 using Tab5_DiD, append excel  symbol(***, **, *)
xi: reg price IT_pXPC IT_p  pcai   time, vce( cluster _j)
outreg2 using Tab5_DiD, append excel  symbol(***, **, *)
xi: reg price IT_pXPC IT_p pcai time L(0/4).brenteuml  , vce(cluster _j)
outreg2 using Tab5_DiD, append excel  symbol(***, **, *)
xi: reg price IT_pXPC IT_p   pcai time  L(0/4).brenteuml  i.yr i.month  , vce(cluster _j)
outreg2 using Tab5_DiD, append excel  symbol(***, **, *)

***********************************************
***Figure 2 - Italian Price, Brent, EU Price***
***********************************************
use "$output\EU_Data_Analysis.dta", clear
tsset Date
format Date %tdMon_CCYY

tw( tsline Mean_EU, lp(dash)) (tsline price1) (tsline brenteuml, lpattern("-.-.")), ///
tline(11oct2004) tline(21mar2005) ///
legend(label( 1 "Mean EU Gasoline Price") label( 2 "Mean Italian Gasoline Price") ///
label( 3 "Brent Price in the EU")) ///
xtitle("") xsize(12) ysize(7) title("Figure II: Italian Price, EU Price and Brent") ///
tlabel(06jan2003(185)31jan2005 02may2005)  ytitle("Price (Euro per 1000 Liters)") ///
saving(Fig2_EUPrices, replace)
 
******************************************************************************** 
*************************End   - Second Part ***********************************
********************************************************************************
 
 
 
******************************************************************************** 
*************************Start - Third Part  ***********************************
********************************************************************************
 
****************************************
*** Figure 5 - Synthetic control	 ***
****************************************
use "$output\EU_Data_Analysis.dta", clear

// Create strongly balanced panel - no missing values
egen miss=rowmiss(price1-price9)
drop if miss==9
reshape long price, i(Date)
xtset _j Date
bys _j: gen time=_n
xtset _j  time

synth price price, tru(1) trp(89) keep("Synth_Replication.dta", replace)

drop if _j!=1
keep time Date brenteuml
rename time _time
save "$output\Synth_Date_Merge.dta", replace

use "$output\Synth_Replication.dta", clear
merge 1:1 _time using "$output\Synth_Date_Merge.dta"
tsset Date, daily
gen pcai=(Date>td(06oct2004))

gen truntr_dif=_Y_treated - _Y_synthetic

// Left panel
graph tw (tsline _Y_treated   )  (tsline _Y_synthetic , lpattern(dash) )   ///
, tline(11oct2004)  legend( cols(1) label( 1 "Italian Gasoline Price")  ///
label( 2 "Synthetic Control")) xtitle("") ytitle("Price (Euro per 1000 Liters)")   ///
tlabel(06jan2003(185)31jan2005, format(%tdMon_CCYY)) tline(11oct2004) name(one, replace)

// Effect
sum truntr_dif if pcai==0
local mean_pre= r(mean)
sum truntr_dif if pcai==1
local mean_post= r(mean)

tsset _time

// Right panel
tw (tsline truntr_dif ) (function y=`mean_pre', lcolor(black) range(0 89 ))  ///
(function y=`mean_post', lcolor(black) range(89 119 )), ytitle("Price Difference") ///
xlabel( 1 "Jan 2003" 26 "Jul 2003" 50 "Jan 2004" 75 "Jul 2004" 100 "Jan 2005") ///
xscale(range (0 120)) ///
legend(label( 1 "Price difference (Italy-Synthetic Control)") ///
label( 2 "Average Price Difference Pre/Post Sticky Pricing ") order(1 2) cols(1)) ///
 xline(89)  name(two, replace)

graph combine one two, ysize(7) xsize(12) title("Figure V: Italian Price and Synthetitc Control") ///
saving(Fig5_Synth, replace)
****************************************
*** Table 6 - Synthetic control	     ***
****************************************
ttest  _Y_treated  =_Y_synthetic
ttest  _Y_treated  =_Y_synthetic if pcai==0
ttest  _Y_treated  =_Y_synthetic if pcai==1 

gen Country=""
replace  Country="Belgium" if _Co_Number==2
replace  Country="Germany" if _Co_Number==3
replace  Country="Spain" if _Co_Number==4
replace  Country="France" if _Co_Number==5
replace  Country="Greece" if _Co_Number==6
replace  Country="Netherlands" if _Co_Number==7
replace  Country="Portugal" if _Co_Number==8
replace  Country="Austria" if _Co_Number==9
list Country _W_Weight if !missing(_W_Weight)

****************************************
*** Table 7 - Synthetic control Reg	 ***
****************************************
reg truntr_dif pcai, r
outreg2 using Tab7_SynthReg, replace excel  symbol(***, **, *)
reg truntr_dif pcai L(0/4)D.brenteuml , r
outreg2 using Tab7_SynthReg, append excel  symbol(***, **, *)
reg truntr_dif pcai L(0/4)D.brenteuml _time , r 
outreg2 using Tab7_SynthReg, append excel  symbol(***, **, *)

******************************************************************************** 
*************************End   - Third Part  ***********************************
********************************************************************************


******************************************************************************** 
*************************Start   - Fourth Part  ********************************
********************************************************************************

************************************
*** Table 9 - In time placebo 	 ***
************************************
use "$output\EU_Data_Analysis.dta", clear
gen time=_n
reshape long price, i(Date)
xi, noomit i._j
sort _j time 
drop if pcai==1 
gen IT_p=0
replace IT_p=1 if _j==1
	
	forvalues i = 20(5)65 {
		 
	local k= `i'-1
		 
	gen treat_`i'=0
	replace treat_`i'=1 if time>`k'
	
	}

	forvalues i = 20(5)65 {
	
	local k= `i'-1

	
	gen placeboIT_`i' = 0 
	replace placeboIT_`i' =1 if treat_`i'==1 & _j==1
	
	
	}


	forvalues i = 20(5)65{
	 
	 if `i'==20  {
	 
	 reg price placeboIT_`i' IT_p  treat_`i'  , r
	 outreg2 using Tab9_InTime, replace excel  symbol(***, **, *)

	 }
	 
	 else {
	 
	 reg price placeboIT_`i' IT_p  treat_`i'  , r
	 outreg2 using Tab9_InTime, append excel  symbol(***, **, *)

	 }
	 }



****************************************
*** Table 10 - In state placebo 	 ***
****************************************
use "$output\EU_Data_Analysis.dta", clear

drop price1
reshape long price, i(Date)
xi, noomit i._j

	forvalues i = 2/9 {
	
	gen placeboDID_`i' = 0 
	replace placeboDID_`i' =1 if pcai==1 & _j==`i'
	
	
	}
	
	forvalues i = 2/9{
	 
	 if `i'==2  {
	 
	 reg price placeboDID_`i' _I_j_`i' pcai , r
	 outreg2 using Tab10_InState, replace excel  symbol(***, **, *)

	 }
	 
	 else {
	 
	 reg price placeboDID_`i' _I_j_`i' pcai , r
	 outreg2 using Tab10_InState, append excel  symbol(***, **, *) 

	 }
	 }


******************************************************************************** 
*************************  END   - Fourth Part  ********************************
********************************************************************************





******************************************************************************** 
********************** END OF REPLICATION DO-FILE ******************************
********************************************************************************
